package org.bwapi.bridge.model;

import java.util.Set;

import org.apache.commons.collections15.Transformer;
import org.bwapi.bridge.swig.DamageTypeSet;
import org.bwapi.bridge.swig.DamageTypeSetIterator;
import org.bwapi.bridge.swig.SWIGTYPE_p_std__setT_BWAPI__DamageType_t;
import org.bwapi.bridge.swig.bridge;
import org.cretz.swig.collection.NativeSet;


/**
 * Damage type
 * 
 * @see <a href="http://code.google.com/p/bwapi/wiki/DamageType">DamageType</a>
 * 
 * @author Chad Retz
 */
public class DamageType extends BwapiComparable<DamageType> {
	
	private static final Transformer<DamageType, org.bwapi.bridge.swig.DamageType> FROM = 
		new Transformer<DamageType, org.bwapi.bridge.swig.DamageType>() {
			@Override
			public org.bwapi.bridge.swig.DamageType transform(DamageType type) {
				return type.getDamageType();
			}
		};
		
	private static final Transformer<org.bwapi.bridge.swig.DamageType, DamageType> TO = 
		new Transformer<org.bwapi.bridge.swig.DamageType, DamageType>() {
			@Override
			public DamageType transform(org.bwapi.bridge.swig.DamageType type) {
				return new DamageType(type);
			}
		};
	
	public static final DamageType INDEPENDENT = new DamageType(bridge.getDamageTypeIndependent());
	public static final DamageType EXPLOSIVE = new DamageType(bridge.getExplosive());
	public static final DamageType CONCUSSIVE = new DamageType(bridge.getConcussive());
	public static final DamageType NORMAL = new DamageType(bridge.getDamageTypeNormal());
	public static final DamageType IGNORE_ARMOR = new DamageType(bridge.getIgnore_Armor());
	public static final DamageType NONE = new DamageType(bridge.getDamageTypeNone());
	public static final DamageType UNKNOWN = new DamageType(bridge.getDamageTypeUnknown());
	
	public static Set<DamageType> allDamageTypes() {
		return newSet(bridge.allDamageTypes());
	}
    
    /**
     * Not implemented
     * 
     * @param name
     * @return
     * 
     * @deprecated Not implemented
     */
    @Deprecated
    public static DamageType getDamageType(String name) {
    	throw new UnsupportedOperationException();
    }
	
	static Set<DamageType> newSet(SWIGTYPE_p_std__setT_BWAPI__DamageType_t nativeSet) {
		return new NativeSet<DamageType, org.bwapi.bridge.swig.DamageType>(
				org.bwapi.bridge.swig.DamageType.class, DamageTypeSetIterator.class, 
				nativeSet, DamageTypeSet.class, FROM, TO);
	}
	
	private final org.bwapi.bridge.swig.DamageType damageType;
	
	DamageType(org.bwapi.bridge.swig.DamageType damageType) {
		this.damageType = damageType;
	}
	
	public DamageType() {
		this(new org.bwapi.bridge.swig.DamageType());
	}

	public DamageType(int id) {
		this(new org.bwapi.bridge.swig.DamageType(id));
	}

	public DamageType(DamageType other) {
		this(new org.bwapi.bridge.swig.DamageType(other.getDamageType()));
	}
	
	org.bwapi.bridge.swig.DamageType getDamageType() {
		return damageType;
	}

	@Override
	public DamageType opAssign(DamageType other) {
		return new DamageType(damageType.opAssign(other.getDamageType()));
	}

	@Override
	public boolean opEquals(DamageType other) {
		return damageType.opEquals(other.getDamageType());
	}

	@Override
	public boolean opNotEquals(DamageType other) {
		return damageType.opNotEquals(other.getDamageType());
	}

	@Override
	public boolean opLessThan(DamageType other) {
		return damageType.opLessThan(other.getDamageType());
	}

	@Override
	public int getID() {
		return damageType.getID();
	}

	public String getName() {
		return damageType.getName();
	}
}
